﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Security.Cryptography;
using System.Text;

namespace park
{
    public class BasePage:Page
    {
        public bool UserOnline
        {
            get { return Session["username"] != null; }
        }

        public string UserPwd
        {
            get
            {
                if (Session["userpwd"] == null)
                {
                    return null;
                }
                return Session["userpwd"].ToString();
            }

            set
            {
                Session["userpwd"] = value;
            }
        }

        public string UserName
        {
            get
            {
                if (Session["username"] == null)
                {
                    return null;
                }
                return Session["username"].ToString();
            }

            set
            {
                Session["username"] = value;
            }
        }

        public string EncryptToMD5(string str)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] str1 = Encoding.UTF8.GetBytes(str);
            byte[] str2 = md5.ComputeHash(str1, 0, str1.Length);
            md5.Clear();
            (md5 as IDisposable).Dispose();
            return Convert.ToBase64String(str2);
        }
    }
}